package com.gdzn.netty.enums;


/**
 * 设备是否在线枚举定义
 */
public enum DeviceOnlineEnum {
    NO("0","离线"),
    YES("1","在线");

    private String code;
    private String desc;

    DeviceOnlineEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }


    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 自己定义一个静态方法,通过code返回枚举常量对象
     * @param code
     * @return
     */
    public static DeviceOnlineEnum getValue(String code) {
        for (DeviceOnlineEnum key : values()) {
            if (key.getCode().equals(code)) {
                return key;
            }
        }
        return null;
    }


}
